﻿using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Skywalker.Fluently.Tests.Fakes;

namespace Skywalker.Fluently.Tests.DefaultComponentBuilder_Tests
{
    [TestClass]
    public class add_item
    {
        [TestMethod]
        public void adds_the_specified_item_to_the_component()
        {
            // Arrange
            var builder = new DefaultBuilder<TestComponent>();
            var expectedItem = new object();

            // Act
            builder.Add(x => x.Items, expectedItem);

            // Assert
            Assert.AreSame(expectedItem, builder.Component.Items.First());
        }

        [TestMethod]
        public void returns_the_builder()
        {
            // Arrange
            var builder = new DefaultBuilder<TestComponent>();

            // Act
            var returnedBuilder = builder.Add(x => x.Items, new object());

            // Assert
            Assert.AreSame(builder, returnedBuilder);
        }
    }
}
